package com.spddr.pmos.jpa;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Embeddable
public class ReservoirLevelVolumeId implements java.io.Serializable {
	private static final long serialVersionUID = 1L;

	private long reservoir;
	private BigDecimal waterLevel;

	public ReservoirLevelVolumeId() {
	}

	public ReservoirLevelVolumeId(long reservoir, BigDecimal waterLevel) {
		this.reservoir = reservoir;
		this.waterLevel = waterLevel;
	}

	@JsonIgnore
	@Column(name = "reservoir", nullable = false)
	public long getReservoir() {
		return this.reservoir;
	}

	public void setReservoir(long reservoir) {
		this.reservoir = reservoir;
	}

	@Column(name = "water_level", nullable = false, precision = 6)
	public BigDecimal getWaterLevel() {
		return this.waterLevel;
	}

	public void setWaterLevel(BigDecimal waterLevel) {
		this.waterLevel = waterLevel;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (reservoir ^ (reservoir >>> 32));
		result = prime * result + ((waterLevel == null) ? 0 : waterLevel.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ReservoirLevelVolumeId other = (ReservoirLevelVolumeId) obj;
		if (reservoir != other.reservoir)
			return false;
		if (waterLevel == null) {
			if (other.waterLevel != null)
				return false;
		} else if (!waterLevel.equals(other.waterLevel))
			return false;
		return true;
	}
}